﻿
var htmlUrl = document.location.host;
var port=document.location.port;
if(htmlUrl == "")
{       
        htmlUrl = "http://localhost:"+port;
}
else
{
        htmlUrl = "http://" + htmlUrl;
}
var arr1=[];
var url=document.URL; 	
var para=""; 
var ids=[];
var area="";
var community="";
var cwsl="";
var ffff="";
var floor="";
var krngw="";
var leaseterm="";//最短租期
var price="";
var rentable="";//起租时间
var sfkzc="";
var zj ="";
var zxqk="";//装修情况
var title="";
var housezj="";
var gdbgj = "";//隔断办公间
var html="";
//var hsid="";
var roomNo;
var btncount = 1;//全局变量用来记录是全景周边还是3d楼盘
var longitude,latitude;
var promisehouse;
var promisemodellczx;//乐成中心增加的一个楼图层

//var roomNo;

var fwurl = requestUrl();
var imgurl = getImgUrl();
//$(function(){
	var html = '';//添加元素的html代码 
	//房源中的收藏
	   ajax("/api/v1/user/opt/houseCollectionNum",'post',{houseId:houseid},function(result){
		if(result.code == 200){
			$("#shoucang").html(result.data+"人收藏");
		}
	   },false);
	   
	   var building3dNo = "";
if(brochureId != "" &&brochureId != null){
			ajax("/api/v1/brochure/brochureUserInfo",'post',{brochureId:brochureId},function(result){
				if(result.code == 200){
					$("#phone").attr("data-original-title",result.data.phone);
				}
			   },false);
		}
	//房源信息
		ajax("/api/v1/building/houseInfo",'post',{houseId:houseid},function(result){
			if(result.code == 200){
				longitude = result.data.longitude;
				latitude = result.data.latitude;
				 point1 = new BMap.Point(parseFloat(longitude),parseFloat(latitude));
				 var myIcon = new BMap.Icon("http://api.map.baidu.com/img/markers.png", new BMap.Size(23, 25), {  
					offset: new BMap.Size(10, 25), // 指定定位位置  
					imageOffset: new BMap.Size(0, 0 - 10 * 25) // 设置图片偏移  
				});   
				var marker = new BMap.Marker(point1,{icon:myIcon});
				//marker.setLabel(new BMap.Label(commname));
				map.addOverlay(marker);
				var circle = new BMap.Circle(point1,1000,{fillColor:"#ccc", strokeWeight: 1 ,fillOpacity: 0.2, strokeOpacity: 0.2});
				btn("jt","地铁");	
				var address = result.data.address;//地址
				building3dNo = result.data.building3dNo;
				var name = result.data.buildingName;//楼盘名称
				var lpdz1 = result.data.buildingAddress;//楼盘地址
				var kfs = result.data.developer;//开发商
				var title = result.data.houseTitle;//房源标题
				var lpjs = result.data.introduce;//房源荐语
				var qzsj = result.data.hireTime;//起租时间
				var zxqk = result.data.fitmentStatus;//装修状况：1：毛坯；2：标配简装；3：遗留装修
				var szhx = result.data.loopName;//所在环线
				var phone = result.data.phone;//发布人电话
				var price = result.data.price;//单价：元/平米每天
				var area = result.data.area;//面积
				var zj = price*30*area/10000;
				var sjsj = result.data.releaseTime;//上架时间
				if(sjsj!=null&&sjsj!="null"){
					var sjs=sjsj.substring(0,sjsj.length-9);
					$("#sjsj").html("上架："+sjs);
				}
				roomNo = result.data.roomNo;//房号
				var zdzq = result.data.minTenancy;//最短租期
				var jzmj = result.data.totalArea;//总面积
				var gdbgj = result.data.separationNum;//隔断办公间数量
				var zglc = result.data.totalFloors;//最大楼层
				//result.data.townName;//区县名称
				//result.data.tradingArea;//商圈
				var ya = result.data.deposit;//付款方式压几个月
				var fu = result.data.payment;//付款方式付几个月的
				var sssq = result.data.tradingName;//商圈名称
				var gwzx = result.data.minStation//可容纳最小工位数
				var gwzd = result.data.maxStation//可容纳最大工位数
				var sfkzc = result.data.registerFlag;//是否注册公司 0否 1是
				var chaoxiang = result.data.orientation;//朝向 0东 1南 2西 3北
				var lptp = result.data.buildingImg;//楼盘图片
				var jcnd = result.data.buildingYear;//建成年代
				var ldsl = result.data.totalNum;//栋数
				$("#lpdz").html(address);
				$("#title").html(title);
				$("#mianji").html(area);
				$("#price").html(price);
				if(roomNo){
					$("#roomNo").html(roomNo);
				}
				$("#zj").html(zj.toFixed(1));
				$("#qzsj").html(qzsj);
				$("#zdzq").html(zdzq+"个月");
				$("#gdbgj").html(gdbgj);
				$("#fkfs").html("押"+formNumber(ya)+" 付"+formNumber(fu));
				$("#krngw").html(gwzx+"~"+gwzd);
				if(sfkzc == '0'){
					$("#sfkzc").html('否');
				}else{
					$("#sfkzc").html('是');
				}
				
				if(brochureId == ""||brochureId == null){
					$("#phone").attr("data-original-title",phone);
				}
				
				$("#lpjs").html(lpjs);
				$("#jcnd").html(jcnd+"年");
				$("#jzmj").html(jzmj+"m²");
				$("#sssq").html(sssq);
				$("#ldsl").html(ldsl+"栋");
				$("#szhx").html(szhx);
				$("#zglc").html(zglc+"层");
				$("#kfs").html(kfs);
				$("#lpdz1").html(lpdz1);
				$("#name").html(name);
				$("#lptp").attr("src", getDefaultImg(lptp));
				if (result.data.building3dNo) {
					$("#three-click").show();
					// var str =
					//   '<a style="margin-left:5px;" href="javascript:;" data-type="three-d">3D</a>';
					// $("#img-3D-tab").append(str);
				  } else {
					$("#three-click").hide();
				  }
				if (result.data.companyType == 1) {
					housebrowse(result.data.buildingId);
					
					setTimeout(function(){
						issuerKfs(result.data);
					},1000)
				  } else if (result.data.companyType == 2) {
					housebrowse(result.data.corrId);
					houseconsulting("1", result.data.corrId);
					setTimeout(function(){
						issuerZcgl(result.data.corrId);
					},1000)
				  } else if (result.data.companyType == 3) {
					houseconsulting("2", result.data.userId);
					setTimeout(function(){
						issuerZj(result.data.userId);
					},1000)
				  } else {
					$(".issue-per").remove();
				  }
				switch (zxqk) {
					case "1":
					  zx = "毛坯";
					  break;
					case "2":
					  zx = "标配简装";
					  break;
					case "3":
					  zx = "遗留装修";
					  break;
					case "4":
					  zx = "拎包入住";
					  break;
				  }
				  $("#zxqk").html(zx);
				var arr = ["东", "南", "西", "北"],
        			str = "";
				var oriList = chaoxiang.split(",");
				for (var i = 0, j = oriList.length; i < j; i++) {
					str += " " + arr[oriList[i]];
				}
				$("#chaoxiang").html(str);
				$("#subwayDistanceName").html(result.data.subwayDistanceName);
				//yzfh(roomNo);
				/*for(var i=0;i<result.result.length;i++){
					$(".swiper-wrapper").append('<div class="swiper-slide">'+
							'<img src="'+result.data.buildingImg+'">'+
						'</div>');
					
				}*/
			}
		})
		function goMain(){
			window.open("./main.html?name=" + building3dNo + "&cnt=0&buildid=" + getParams('buildid') + "")
		}
	//房源周边推荐  下列
	   ajax("/api/v1/building/recommendedBuildingNearby","post",{buildingId:buildid},function(result){
		if(result.code == 200 && result.data != null){
			var imgurl1 = fwurl+"/image/";
			for(var i=0;i < result.data.length; i++){
				  directFlag = "",
          				buildingFlag = "";
 if (result.data[i].directFlag == 1) {
          directFlag = "直租计划"; 
        } else {
          directFlag = "";
        }
        if (result.data[i].buildingFlag == 1) {
          buildingFlag = '<img src="static/ffyxq/images/3D.svg"></a>';
        } else {
          buildingFlag = "";
        }
				$("#zbtj2").append('<li>'+
						'<div class="small-pro-list-info" style="cursor:pointer" onclick="goFxfyxq(\'' +
						result.data[i].buildingName +
						"','" +
						result.data[i].buildingId +
						'\')">'+
						'<div class="pic">'+
							'<img src="'+getDefaultImg(result.data[i].imgUrl)+'">'+
							'<a href="javascript:;" class="threeD">'+
							buildingFlag +
							"" +
						'</div>'+
						'<div class="remark">'+
							'<div class="clearfix">'+
								'<a href="javascript:;" class="ellipsis-1 pull-left" style="width:150px;">'+result.data[i].buildingName+'</a>'+
							   '<span class="zhizu-plan pull-right">'+directFlag+'</span>'+
							'</div>'+
							'<div class="detail-info clearfix">'+
								'<div class="pull-left">'+result.data[i].minArea+'m²-'+result.data[i].maxArea+'m²在租</div>'+
								'<div class="pull-right" style="line-height:17px;">'+
									'<span class="blue" style="font-size:16px;">'+result.data[i].price+'</span>'+
									'<small> 元/m²·天</small>'+
								'</div>'+
							'</div>'+
						'</div>'+
					'</div>'+
				'</li>')
			}
		}
	   },false)

	   function goFxfyxq(name,id){
		window.open("/three/main.html?name=" + name + "&cnt=0&buildid=" + id);
        
	   }




//})
function onload(Cesium){
	if(dzc_service != undefined){
		viewer = new Cesium.Viewer("scenediv",{
			 terrainProvider : new Cesium.CesiumTerrainProvider({
					url : dzc_service.serverurllayers.terrain,
					requestWaterMask : true,//是否请求水面标志位（用于水面特效），默认不请求
					requestVertexNormals : true,//是否请求法线（用于光照效果），默认不请求
					isSct : true//是否为iServer发布的TIN地形服务
				}) 
	});
		 var sql="LPBH ='"+commname+"'";
			var queryconfig={
			        url:dataurl,
			        sql:sql,
			        layerName:dzc_service.layers.layerhousehold,
			        datalayerName:dzc_service.datalayers.layerhousehold,
			        callback:processCompletedcxlp
			    };
			_queryBySql(queryconfig);
		yzfh(roomNo);
		scene = viewer.scene;	
		imageryLayers = viewer.imageryLayers;
		//添加影像
		var imageryProvider1 = new Cesium.SuperMapImageryProvider({
			url :  dzc_service.serverurllayers.imageWhiteBase	
		})
		var widget = viewer.cesiumWidget;
		var layer1 = imageryLayers.addImageryProvider(imageryProvider1);
		var imageryProviderdom = new Cesium.SuperMapImageryProvider({
			url :dzc_service.serverurllayers.Dom['HM']
		})
		layerdom = imageryLayers.addImageryProvider(imageryProviderdom);
		layerdom.show = false;
		scene.screenSpaceCameraController.enableZoom = false;
		scene.sun.show = false;
		 //添加鼠标移动事件，功能实现指北针方位和场景方位一致
		 var handler = new Cesium.ScreenSpaceEventHandler(viewer.scene.canvas);
		 handler.setInputAction(function (movement) {
			 var heading = scene.camera.heading;
			 var ss = heading*180/3.14;
			 document.getElementById("img1").style.transform = "rotate("+ -ss +"deg)";
		 }, Cesium.ScreenSpaceEventType.MOUSE_MOVE); 
		 viewer.cesiumWidget.screenSpaceEventHandler.removeInputAction(Cesium.ScreenSpaceEventType.LEFT_DOUBLE_CLICK);
		 //$(".BMapLabel").css({"border":"0px"});//去掉百度地图中label的边框
		 $("#qjzbbtn").click(function(){
			if($(this)[0].innerHTML == "全景周边"){
				btncount = 0;
				viewer.entities.removeAll();
				viewer.entities._show = true;
				$("#qjzbbtn").html("3D楼盘");

					promisemodel.then(function(layer){
						 layer.visible = true;
					 });
					 promisemodel12.then(function(layer){
					    layer.selectEnabled = false;
					    layer.visible = true;
					 });
					 if(commname == "BJCY010" || commname == "乐成中心"){
						 promisemodellczx.then(function(layer){
							 layer.selectEnabled = false;
						     layer.visible = true;
						 });
					 }
					 layerdom.show = true;
					 reset();
	    			 mark();//全景周边中楼标注
			}else{
				btncount=1;
				viewer.entities.removeAll();
				$("#qjzbbtn").html("全景周边");
				viewer.entities._show = true;
				louhao();

					promisemodel.then(function(layer){
				    	$("#ditu").css({"display":"none"});
						$("#gif").css({"display":"none"});
				    	layer.selectEnabled = false;
				    	layer.visible = true;
				    });
					 promisemodel12.then(function(layer){
					    	layer.selectEnabled = false;
					    	layer.visible = false;
					    });
					 if(commname == "BJCY010" || commname == "乐成中心"){
						 promisemodellczx.then(function(layer){
							 layer.selectEnabled = false;
						     layer.visible = false;
						 });
					 }

				layerdom.show = false;
				reset();
				var arr = viewer.entities.values;
		
			}
		});
		
		promisemodel = scene.addS3MTilesLayerByScp(dzc_service.serverurllayers.Model['HM'],{
	        name : 'model'
		});
		promisemodel12 = scene.addS3MTilesLayerByScp(dzc_service.serverurllayers.Model['HM12'],{
			 name : "model12"
		 });
		 if(commname == "BJCY010" || commname == "乐成中心"){
				promisemodellczx = scene.addS3MTilesLayerByScp(dzc_service.serverurllayers.Model['LCZX'],{
					 name : "modellczx"
				 });
				promisemodellczx.then(function(layer){
					 layer.selectEnabled = false;
				     layer.visible = false;
				 });
			}
		 promisemodel12.then(function(layer){
			 layer.selectEnabled = false;
		     layer.visible = false;
		     layer.lodRangeScale = 0.2;
		 });
		 promisemodel.then(function(layer){
		 	layer.selectEnabled = false;
		 	layer.visible = true;
		 	layer.lodRangeScale = 0.2;
		 });
		 promisehouse = scene.addS3MTilesLayerByScp(dzc_service.serverurllayers.Household,{
		     name : 'household'
		 });
		 
		 promisehouse.then(function(layer){
		 	layer.setQueryParameter({//设置查询参数
		         url: dataurl,
		         dataSourceName: 'AttachData',//数据源
		         dataSetName: 'Household',//数据集
		     });
		 	layer._selectColorType = 1;
		 	layer.selectEnabled = true;
		 	layer.visible = false;
		 	//layer.setObjsVisible([9098,9114],true);
			//layer.setObjsColor([9098,9114],new Cesium.Color(0,139/255,210/255,1));
		 });
		 //yzfh(hsid);
		 if(btncount == 0){
				Range = 474;
				var transform = Cesium.Transforms.eastNorthUpToFixedFrame(Cesium.Cartesian3.fromDegrees(116.47466421824433-0.00000000045916, 39.90788091996372,tranheight));
				var heading = Cesium.Math.toRadians(parseInt(lpheading));
				var pitch = Cesium.Math.toRadians(-35.0);
				var range = 474.0;
				scene.camera.lookAtTransform(transform, new Cesium.HeadingPitchRange(heading, pitch, range));
			}else{
				Range = range1;
				var transform = Cesium.Transforms.eastNorthUpToFixedFrame(Cesium.Cartesian3.fromDegrees(center.x-0.00000000045916, center.y,tranheight));
				 var heading = Cesium.Math.toRadians(parseInt(lpheading));
				 var pitch = Cesium.Math.toRadians(pitchcsh);
				 var range = range1;
				 scene.camera.lookAtTransform(transform, new Cesium.HeadingPitchRange(heading, pitch, range));
			}
		louhao();//显示出楼号
	}
}
//根据楼盘编号查询楼盘名字
function processCompletedcxlp(result){
	console.log(result);
}
//初始化显示户
function yzfh(RoomNo){
	var str="";
 	str = str + " RoomNo = '" + RoomNo + "' and LPBH = '"+commname+"'";
	var string="";
	var sql= str;
	var queryconfig={
	        url:dataurl,
	        sql:sql,
	        layerName:dzc_service.layers.layerhousehold,
	        datalayerName:dzc_service.datalayers.layerhousehold,
	        callback:processCompletedhouse
	    };
		_queryBySql(queryconfig);
}
function processCompletedhouse(getFeaturesEventArgs) {
	var array = [];	
	var list = getFeaturesEventArgs.originResult.features;
	var count = getFeaturesEventArgs.originResult.featureCount;
	for(var j = 0; j < list.length; j++){
		var smid = getFeaturesEventArgs.originResult.features[j].ID;
		array.push(smid);
	}
	if(count > 0 ){
		promisehouse.then(function(layer){
		 	layer._selectColorType = 1;
		 	layer.selectEnabled = true;
		 	layer.visible = true;
		 	layer.setObjsVisible(array,true);
			layer.setObjsColor(array,new Cesium.Color(0,139/255,210/255,1));
		 });
	}
}
//全景周边中标注
function mark(){
	$.ajax({
	    url: "js/js/marker.json",
	    type: "GET",
	    dataType: "json",
	    async : false,
	    success: function (data) {
	    	//添加文字和图片
	    	for(var i =0; i < data.length; i++){
	    		if(commname == data[i].name){
	    			for(var j = 0; j < data[i].datas[0].wenimg.length;j++){
	    				var temp = data[i].datas[0].wenimg[j].position;
	    				var result = temp.split(",");
	    				if(result.length>0){
	    					var long = result[0];
	    					var lat = result[1];
	    					var height = result[2];
	    					}
	    				var temp1 = data[i].datas[0].wenimg[j].pixelOffset;
	    				var result1 = temp1.split(",");
	    				if(result1.length>0){
	    					var left = result1[0];
	    					var right = result1[1];
	    					}
	    				 var citizensBankPark = viewer.entities.add({
	    					   id:data[i].datas[0].wenimg[j].id,
	    					    name :data[i].datas[0].wenimg[j].name,
	    					    position : Cesium.Cartesian3.fromDegrees(parseFloat(long),parseFloat(lat),parseFloat(height)),
	    					    billboard : { 
	    					        image : data[i].datas[0].wenimg[j].billboard,
	    					        width : 32,
	    					        height : 32
	    					    },
	    					    label : { //文字标签
	    					        text : data[i].datas[0].wenimg[j].text,
	    					        outlineWidth : 0,
	    					        outlineColor:  Cesium.Color.YELLOW,
	    					        showBackground : true,
	    					        backgroundColor:new Cesium.Color(0, 0, 0, 0.4),
	    					        fillColor:Cesium.Color.YELLOW,
	    					        font:'15px SimHei',
	    					        verticalOrigin : Cesium.VerticalOrigin.LEFT, //垂直方向以底部来计算标签的位置
	    					        pixelOffset :  new Cesium.Cartesian2( parseFloat(left), parseFloat(right))   //偏移量
	    					    }
	    					} );
	    			}
	    		}
	    	}
	    	//添加图片
	    	for(var i =0; i < data.length; i++){
	    		if(commname == data[i].name){
	    			for(var j = 0; j < data[i].datas[0].img.length;j++){
	    				var temp = data[i].datas[0].img[j].position;
	    				var result = temp.split(",");
	    				if(result.length>0){
	    					var long = result[0];
	    					var lat = result[1];
	    					var height = result[2];
	    					}
	    				var citizensBankPark = viewer.entities.add( {
	    				 	id : data[i].datas[0].img[j].id,
	    				    name : data[i].datas[0].img[j].name,
	    				    position : Cesium.Cartesian3.fromDegrees(parseFloat(long),parseFloat(lat),parseFloat(height)),
	    				    billboard : { //图标
	    				        image :data[i].datas[0].img[j].image,
	    				        width : 32,
	    				        height : 32
	    				    }
	    				} );
	    			}
	    		}
	    	}
	    	//添加楼号
	    	for(var i =0; i < data.length; i++){
	    		if(commname == data[i].name){
	    			for(var j = 0; j < data[i].datas[0].louhao.length;j++){
	    				var temp = data[i].datas[0].louhao[j].position;
	    				var result = temp.split(",");
	    				if(result.length>0){
	    					var long = result[0];
	    					var lat = result[1];
	    					var height = result[2];
	    					}
	    				var citizensBankPark = viewer.entities.add({
	    					   id:data[i].datas[0].louhao[j].id,
	    					    name : data[i].datas[0].louhao[j].name,
	    					    position : Cesium.Cartesian3.fromDegrees(parseFloat(long),parseFloat(lat),parseFloat(height)),
	    					    label : { //文字标签
	    					        text : data[i].datas[0].louhao[j].text,
	    					        outlineWidth : 0,
	    					        outlineColor:  Cesium.Color.WHITE,
	    					        showBackground : true,
	    					        backgroundColor:new Cesium.Color(0, 0, 0, 0.4),
	    					        fillColor:Cesium.Color.WHITE,
	    					        font:'18px SimHei',
	    					        verticalOrigin : Cesium.VerticalOrigin.BOTTOM, //垂直方向以底部来计算标签的位置
	    					        pixelOffset :  new Cesium.Cartesian2( 0, -9 )  //偏移量
	    					    }
	    					} );
	    			}
	    		}
	    	}   
	    	//添加文本
	    	for(var i =0; i < data.length; i++){
	    		if(commname == data[i].name){
	    			for(var j = 0; j < data[i].datas[0].wenben.length;j++){
	    				var temp = data[i].datas[0].wenben[j].position;
	    				var result = temp.split(",");
	    				if(result.length>0){
	    					var long = result[0];
	    					var lat = result[1];
	    					var height = result[2];
	    					}
	    				var citizensBankPark = viewer.entities.add({
	    					   id:data[i].datas[0].wenben[j].id,
	    					    name : data[i].datas[0].wenben[j].name,
	    					    position : Cesium.Cartesian3.fromDegrees(parseFloat(long),parseFloat(lat),parseFloat(height)),
	    					    label : { //文字标签
	    					        text : data[i].datas[0].wenben[j].text,
	    					        outlineWidth : 0,
	    					        outlineColor:  Cesium.Color.YELLOW,
	    					        showBackground : true,
	    					        backgroundColor:new Cesium.Color(0, 0, 0, 0.4),
	    					        fillColor:Cesium.Color.YELLOW,
	    					        font:'15px SimHei',
	    					        verticalOrigin : Cesium.VerticalOrigin.BOTTOM, //垂直方向以底部来计算标签的位置
	    					        pixelOffset : new Cesium.Cartesian2( 0, -9 )   //偏移量
	    					    }
	    					} );
	    			}
	    		}
	    	}	
	    	//添加道路
	    	for(var i =0; i < data.length; i++){
	    		if(commname == data[i].name){
	    			for(var j = 0; j < data[i].datas[0].daolu.length;j++){
	    				var temp = data[i].datas[0].daolu[j].position;
	    				var result = temp.split(",");
	    				if(result.length>0){
	    					var long = result[0];
	    					var lat = result[1];
	    					var height = result[2];
	    				}
	    				var citizensBankPark = viewer.entities.add( {
	    					   id:data[i].datas[0].daolu[j].id,
	    					    name : data[i].datas[0].daolu[j].name,
	    					    position : Cesium.Cartesian3.fromDegrees(parseFloat(long),parseFloat(lat),parseFloat(height)),
	    					    label : { //文字标签
	    					        text : data[i].datas[0].daolu[j].text,
	    					        outlineWidth : 1,
	    					        outlineColor:  Cesium.Color.LIME,
	    					        showBackground : true,
	    					        backgroundColor:new Cesium.Color(0, 0, 0, 0.4),
	    					        fillColor:Cesium.Color.LIME,
	    					        font:'15px SimHei',
	    					        verticalOrigin : Cesium.VerticalOrigin.BOTTOM, //垂直方向以底部来计算标签的位置
	    					        pixelOffset : new Cesium.Cartesian2( 0, -9 )   //偏移量
	    					    }
	    					} );
	    			}
	    		}
	    	}
	    }
	});

}
//3D楼盘展示出楼号
function louhao(){
	$.ajax({
	    url: "js/js/marker.json",
	    type: "GET",
	    dataType: "json",
	    async : false,
	    success: function (data) {
	    	for(var i =0; i < data.length; i++){
	    		if(commname == data[i].name){
	    			for(var j = 0; j < data[i].datas[0].louhao.length;j++){
	    				var temp = data[i].datas[0].louhao[j].position;
	    				var result = temp.split(",");
	    				if(result.length>0){
	    					var long = result[0];
	    					var lat = result[1];
	    					var height = result[2];
	    					}
	    				var citizensBankPark = viewer.entities.add({
	    					   id:data[i].datas[0].louhao[j].id,
	    					    name : data[i].datas[0].louhao[j].name,
	    					    position : Cesium.Cartesian3.fromDegrees(parseFloat(long),parseFloat(lat),parseFloat(height)),
	    					    label : { //文字标签
	    					        text : data[i].datas[0].louhao[j].text,
	    					        outlineWidth : 0,
	    					        outlineColor:  Cesium.Color.WHITE,
	    					        showBackground : true,
	    					        backgroundColor:new Cesium.Color(0, 0, 0, 0.4),
	    					        fillColor:Cesium.Color.WHITE,
	    					        font:'18px SimHei',
	    					        verticalOrigin : Cesium.VerticalOrigin.BOTTOM, //垂直方向以底部来计算标签的位置
	    					        pixelOffset :  new Cesium.Cartesian2( 0, -9 )  //偏移量
	    					    }
	    					} );
	    			}
	    		}
	    	}
	    }
	});
}

function add(){
	$("#fy").attr("src", "images/fuyuan.png");
	$("#fd").attr("src", "images/fda1.png");
	$("#sx").attr("src", "images/suoxiao.png");
	var heading,pitch;
	if(btncount == 0){
		heading = scene.camera.heading;
		//pitch = Cesium.Math.toRadians(-35.0);
		pitch = scene.camera.pitch;
	}else{
		heading = scene.camera.heading;
		//pitch = Cesium.Math.toRadians(-5.0);
		pitch = scene.camera.pitch;
	}
	var transform = Cesium.Transforms.eastNorthUpToFixedFrame(Cesium.Cartesian3.fromDegrees(center.x-0.00000000045916, center.y,tranheight+10));
	if(Range<475 && Range>Rangeheight){
		Range = Range-30;
		
		scene.camera.lookAtTransform(transform, new Cesium.HeadingPitchRange(heading, pitch, Range));

		
	}else{
		if (Range>455)
			{
			Range = 455;
				scene.camera.lookAtTransform(transform, new Cesium.HeadingPitchRange(heading, pitch, Range));
			}
			
		else if(Range < Rangeheight){
			Range = Rangeheight;
			
		}
		else{
			Range = Rangeheight;
			
			}	
	}
}
/**
 * 缩小按钮：根据相机的远离，使看到的模型缩小
 */
function reduce(){
	var heading,pitch;
	if(btncount == 0){
		heading = scene.camera.heading;
		//pitch = Cesium.Math.toRadians(-35.0);
		pitch = scene.camera.pitch;
	}else{
		heading = scene.camera.heading;
		//pitch = Cesium.Math.toRadians(-5.0);
		pitch = scene.camera.pitch;
	}
	$("#fy").attr("src", "images/fuyuan.png");
	$("#fd").attr("src", "images/fangda.png");
	$("#sx").attr("src", "images/sxiao1.png");
	var transform = Cesium.Transforms.eastNorthUpToFixedFrame(Cesium.Cartesian3.fromDegrees(center.x-0.00000000045916, center.y,tranheight+10));
	if(Range<=455 && Range>=Rangeheight){
		Range = Range+30;
		scene.camera.lookAtTransform(transform, new Cesium.HeadingPitchRange(heading, pitch, Range));
		
	}else{
		if (Range>455){
			Range = 455;
		
			
		}
		else{
			Range = Rangeheight;
			
				scene.camera.lookAtTransform(transform, new Cesium.HeadingPitchRange(heading, pitch, Range));

		}	
	}
	
}
/**
 * 复原按钮：初始化场景中相机的方位角和高度
 */
function reset(){
	$("#fy").attr("src", "images/hyuan1.png");
	$("#fd").attr("src", "images/fangda.png");
	$("#sx").attr("src", "images/suoxiao.png");

	
	var pitch;
	if(btncount == 0){
		pitch = Cesium.Math.toRadians(-35.0);
		pitch = scene.camera.pitch;
		Range = 474;
	}else{
		pitch = Cesium.Math.toRadians(pitchcsh);
		pitch = scene.camera.pitch;
		Range = range1;	
	}
	var transform = Cesium.Transforms.eastNorthUpToFixedFrame(Cesium.Cartesian3.fromDegrees(center.x+0.00000000001114, center.y,tranheight+10));
	var heading = Cesium.Math.toRadians(lpheading);
	//var pitch = Cesium.Math.toRadians(-5.0);
	var range2 = Range;
	scene.camera.lookAtTransform(transform, new Cesium.HeadingPitchRange(heading, pitch, range2));
 		
}
//获取咨询次数
function houseconsulting(id, iid) {
	ajax("/api/v1/consult/stats", "post", { type: id, resourceId: iid }, function(
	  data
	) {
	  zxNum = data.data.num;
	});
  }
  //获取浏览量
  function housebrowse(id) {
	ajax("/api/v1/user/opt/countVisit", "post", { id: id, type: "1" }, function(
	  data
	) {
	  lLlNum = data.data;
	});
  }
  	//浏览量
	ajax("/api/v1/user/opt/countVisit",'post',{id:houseid,type:"3"},function(result){
	if(result.code == 200){
		$("#fyyll").html("月浏览"+result.data);
	}
},false)
//发布方-开发商
function issuerKfs(obj) {
	var image = "static/ffyxq/images/noupload.png";
	if (obj.buildingImg) {
	  image = getImgUrl() + obj.buildingImg;
	} else {
	  image = "static/ffyxq/images/noupload.png";
	}
	ajax(
	  "/api/v1/company/companyInfo",
	  "post",
	  { companyId: obj.corrId },
	  function(res) {
		houseconsulting("3", res.data.companyId);
		setTimeout(function(){
			var str =
			"<div class='publisher' onclick='goDetails(1,\"" +
			obj.buildingId +
			'","' +
			obj.building3dNo +
			"\")'>" +
			"<div class='inner'>" +
			"<div class='publisher-img'>" +
			"<img src='" +
			image +
			"'>" +
			"</div>" +
			"<div class='publisher-info'>" +
			"<h3>" +
			res.data.companyName +
			"</h3>" +
			"<span class='special-tag lightblue' style='vertical-align:text-bottom;'>开发商</span>" +
			"<p style='color:#464B5D;'>发布中房源：" +
			res.data.companyHouseNum +
			"（近三个月发布" +
			res.data.quarterNum +
			"）</p>" +
			"<p>" +
			"<span>浏览量：" +
			lLlNum +
			"次</span><span>咨询：" +
			zxNum +
			"次</span>" +
			"</p>" +
			"</div>" +
			"</div>" +
			"</div>";
			$("#fabufang").html(str);
		  },1000)
		
	  }
	);
  }
  
  //发布方-资产管理公司
  function issuerZcgl(id) {
	ajax("/api/v1/company/companyInfo", "post", { companyId: id }, function(res) {
	  var image = "static/ffyxq/images/noupload.png";
	  if (res.data.companyLogo) {
		image = res.data.companyLogo;
	  } else {
		image = "static/ffyxq/images/noupload.png";
	  }
	  var str =
		"<div class='publisher' onclick='goDetails(2,\"" +
		id +
		"\")'>" +
		"<div class='inner'>" +
		"<div class='publisher-img'>" +
		"<img src='" +
		getImgUrl() +
		image +
		"'>" +
		"</div>" +
		"<div class='publisher-info'>" +
		"<h3>" +
		res.data.companyName +
		"</h3>" +
		"<span class='special-tag lightpurple'style='vertical-align:text-bottom;'>资产管理公司</span>" +
		"<p style='color:#464B5D;'>发布中房源：" +
		res.data.companyHouseNum +
		"（近三个月发布" +
		res.data.quarterNum +
		"）</p>" +
		"<p>" +
		"<span>浏览量：" +
		lLlNum +
		"次</span><span>咨询：" +
		zxNum +
		"次</span>" +
		"</p>" +
		"</div>" +
		"</div>" +
		"</div>";
	  $("#fabufang").html(str);
	});
  }
  
  //发布方-中介公司经纪人经纪人
  function issuerZj(id) {
	ajax("/api/v1/broker/brokerInfo", "post", { brokerId: id }, function(res) {
	  var image = "static/ffyxq/images/noupload.png";
	  if (res.data.headPortrait) {
		image = res.data.headPortrait;
	  } else {
		image = "static/ffyxq/images/noupload.png";
	  }
	  var str =
		"<div class='publisher' onclick='goDetails(3,\"" +
		id +
		"\")'>" +
		"<div class='inner'>" +
		"<div class='publisher-img'>" +
		"<img src='" +
		getImgUrl() +
		image +
		"'/>" +
		"</div>" +
		"<div class='publisher-info'>" +
		"<h3>" +
		res.data.brokerName +
		"</h3>" +
		"<span class='special-tag lightorange' style='vertical-align:text-bottom;'>经纪人</span>" +
		"<p style='color:#464B5D;'>发布中房源：" +
		res.data.houseNum +
		"（推送楼书" +
		res.data.buildingBookNum +
		"）" +
		"</p>" +
		"<p><span>楼书分享：" +
		res.data.buildingBookNum +
		"次</span><span>咨询：" +
		zxNum +
		"次</span></p>" +
		"<p><span>所属公司：" +
		res.data.companyName +
		"</span></p>" +
		"</div>" +
		"</div>" +
		"<div class='clearfix' style='width:86%;margin:5px auto 0;'>" +
		"<a href='javascript:;'' class='for-button pull-left' onclick='imgUrlYezf1()'>" +
		"<img src='static/ffyxq/images/agent-1.svg' />从业信息卡</a>" +
		"<a href='javascript:;' class='for-button pull-right' onclick='imgUrlYezf()'>" +
		"<img src='static/ffyxq/images/agent-2.svg' />营业执照</a>" +
		"</div>" +
		"</div>";
	  var image = "static/ffyxq/images/noupload.png";
	  if (res.data.businessLicenseImg) {
		image = res.data.businessLicenseImg;
	  } else {
		image = "static/ffyxq/images/noupload.png";
	  }
	  var image1 = "static/ffyxq/images/noupload.png";
	  if (res.data.businessLicenseImg) {
		image1 = getImgUrl()+res.data.informationImg;
	  } else {
		image1 = "static/ffyxq/images/noupload.png";
	  }
	  var img6 = "<img src='"+ image + "'/>";
	  var img7 = "<img src='"+ image1 + "'/>";
	  $("#fabufang").html(str);
	  $("#maskLayer").html(img6);
	  $("#inforImg").html(img7);
	});
  }
  // 发布方跳转
  function goDetails(type, id, building3dNo) {
	switch (type) {
	  case 1:
		window.location.href =
		  "./main.html?name=" + building3dNo + "&cnt=0&buildid=" + id + "";
		break;
	  case 2:
		window.location.href = "/item/views/others/company.html?id=" + id + "";
		break;
	  case 3:
		window.location.href = "/item/views/others/agency.html?id=" + id + "";
		break;
	}
  }
